package com.kefu.robot.vo;

import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractSearchVo;
import com.kefu.robot.model.RobotAidataDoc;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author xiaoyu
 * @date 2023/11/03
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "AI模型词条")
public class RobotAidataDocSearchVo extends AbstractSearchVo {

    @ApiModelProperty(value = "AI模型id", required = true)
    private String aidataId;
    @ApiModelProperty(value = "分类Id")
    private String docTypeId;
    @ApiModelProperty(value = "名称")
    private String name;
    @ApiModelProperty(value = "类型： 0：文本 1：文件")
    private String type;
    @ApiModelProperty(value = "内容")
    private String content;
    @ApiModelProperty(value = "文件url")
    private String url;
    @ApiModelProperty(value = "创建时间开始")
    private Long createTimeStart;
    @ApiModelProperty(value = "创建时间结束")
    private Long createTimeEnd;
    @ApiModelProperty(value = "创建人")
    private String createUser;
    @ApiModelProperty(value = "更新时间开始")
    private Long updateTimeStart;
    @ApiModelProperty(value = "更新时间结束")
    private Long updateTimeEnd;
    @ApiModelProperty(value = "更新人")
    private String updateUser;

    @Override
    public LambdaQueryWrapper<RobotAidataDoc> lambdaQuery() {
        LambdaQueryWrapper<RobotAidataDoc> wrapper = Wrappers.<RobotAidataDoc>lambdaQuery();
        wrapper.eq(StringUtils.isNotBlank(aidataId), RobotAidataDoc::getAidataId, aidataId);
        wrapper.eq(StringUtils.isNotBlank(docTypeId), RobotAidataDoc::getDocTypeId, docTypeId);
        wrapper.like(StringUtils.isNotBlank(name), RobotAidataDoc::getName, name);
        wrapper.eq(StringUtils.isNotBlank(type), RobotAidataDoc::getType, type);
        wrapper.eq(StringUtils.isNotBlank(content), RobotAidataDoc::getContent, content);
        wrapper.eq(StringUtils.isNotBlank(url), RobotAidataDoc::getUrl, url);
        wrapper.ge(createTimeStart != null, RobotAidataDoc::getCreateTime, createTimeStart);
        wrapper.le(createTimeEnd != null, RobotAidataDoc::getCreateTime, createTimeEnd);
        wrapper.eq(StringUtils.isNotBlank(createUser), RobotAidataDoc::getCreateUser, createUser);
        wrapper.ge(updateTimeStart != null, RobotAidataDoc::getUpdateTime, updateTimeStart);
        wrapper.le(updateTimeEnd != null, RobotAidataDoc::getUpdateTime, updateTimeEnd);
        wrapper.eq(StringUtils.isNotBlank(updateUser), RobotAidataDoc::getUpdateUser, updateUser);
        wrapper.eq(RobotAidataDoc::getTenantId, KefuContext.getKefuContext().getTenantId());

        return wrapper;
    }
}